The entity type String is not part of the model for the current context error [migrated]
Posted
by
Michael V
on Programmers
See other posts from Programmers
or by Michael V
Published on 2012-06-25T18:59:31Z
Indexed on
2012/06/25
21:23 UTC
Read the original article
Hit count: 1021
asp.net-mvc-3
I am getting the following error in my controller after the view submits the collection:
The entity type String is not part of the model for the current context.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The entity type String is not part of the model for the current context.
Source Error:
Line 51: foreach (var survey in mysurveys) Line 52: { Line 53: db.Entry(survey).State = EntityState.Modified; Line 54: Line 55: // db.Entry(survey).State = EntityState.Modified;
Here is the code
` [HttpPost]
public ActionResult UpdateTest(FormCollection mysurveys)
{
System.Diagnostics.Debug.WriteLine("iam in test post" + mysurveys.Count);
foreach (var survey in mysurveys)
{
db.Entry(survey).State = EntityState.Modified;
}
db.SaveChanges();
return View(mysurveys);
}
`Similar code with one record only (no foreach) works fine
© Programmers or respective owner